package com.ashen.study.aop.cglib;

import com.ashen.study.aop.patterns.Subject;
import com.ashen.study.aop.patterns.impl.SubjectImpl;
import org.springframework.cglib.proxy.Enhancer;

/**
 * @author hxl
 * @Classname CglibProxyClient
 * @Description
 * @Date 2019/9/24 18:05
 */
public class CglibProxyClient {
    public static void main(String[] args) throws Exception {
        Enhancer enhancer = new Enhancer();
        //生成指定类对象的子类，也就重写类中的业务函数
        enhancer.setSuperclass(SubjectImpl.class);
        //这是回调函数,加入intercept函数
        enhancer.setCallback(new DemoMethodInterceptor());
        //创建这个子类的对象
        Subject subject = (Subject) enhancer.create();
        subject.access();
    }
}
